import React, { Component } from 'react';

export default class Upload extends Component
{
    async onChange(e: React.ChangeEvent<HTMLInputElement>)
    {
        let input = e.target as HTMLInputElement;
        let pic = new FormData();
        pic.append("pic", input.files !== null ? input.files[0] : "");
        let response = await fetch("http://localhost:3065/getPic", {
            method: "POST",
            body: pic
        });
        let result = await response.json();
        console.log(result);
        console.log(e.target.files);
    }
    render()
    {
        return (
            <div>
                <input onChange={this.onChange} type='file' id='myFile' />
            </div>
        );
    }
}
